<?php require_once(BASEPATH.'application/controllers/validaciones.php');
//Cliente
class bancos extends validaciones {
	
	var $titulo;

	function bancos(){
		parent::Controller(); 
		$this->load->library("rapyd");
		$this->load->library('pi18n');
		$this->titulo=$this->datasis->traevalor('TITULO4');
	}

	function index(){
		redirect("ventas/bancos/filteredgrid");
	}
	function filteredgrid(){
        
        $this->rapyd->load("datagrid2");
		
		$grid = new DataGrid2("Resultado");
        $select=array('codigo','descrip',"a.rifb","IF(tipo='B','Banco','Caja') AS tipo",'cuenta','contacto','telefono','moneda');
		$grid->db->select($select);
		$grid->db->from('bancos AS a');
		$grid->order_by("codigo","ASC");
        //$grid->agrupar(" ",'nombre');
		$grid->per_page=10;  
		
        $uri = anchor('ventas/bancos/dataedit/show/<#codigo#>','<#codigo#>');	
        
        $grid->column("Banco"               ,$uri         ,"align='center'");
        $grid->column("Nombre"              ,"descrip"    ,"align='left'");
        $grid->column("Tipo"                ,"tipo"       ,"align='left'");
        $grid->column("Cuenta"              ,"cuenta"     ,"align='left'");
        $grid->column("Contacto"            ,"contacto"   ,"align='left'");
        $grid->column("Telefono"          ,"telefono"  ,"align='left'");
        $grid->column("RUC"                ,"rifb"  ,"align='left'");
        $grid->column("Moneda"              ,"moneda"  ,"align='left'");
       
		$grid->add("ventas/bancos/dataedit/create");
        
		$grid->build('datagridST');
		//echo $grid->db->last_query();
		
		$cana=$grid->recordCount;
		$grid=$grid->output;
		
		$extras = '
		<script type="text/javascript">
		//<![CDATA[
		(function() {
			var mySt = new superTable("demoTable", {
			cssSkin : "sSky",
			fixedCols : 1,
			headerRows : 1,
			onStart : function () {	this.start = new Date();},
			onFinish : function () {document.getElementById("testDiv").innerHTML += "Finished...<br>" + ((new Date()) - this.start) + "ms.<br>";}
			});
		})();
		//]]>
		</script>
		';
		
		$style ='
		<style type="text/css">
		.fakeContainer { /* The parent container */
		    margin: 5px;
		    padding: 0px;
		    border: none;
		    width: 1000px; /* Required to set */
		    height: 320px; /* Required to set */
		    overflow: hidden; /* Required to set */
		}
		</style>	
		';

		$data['style']   = $style;
		$data['style']  .= style('superTables.css');

		$data['extras']  = $extras;		
		//echo $cana;
		
		$data['content'] = $grid;
	
		$data['content'].= $this->pi18n->fallas();
		$data['filtro']  = ' ';

		$data['title']   = heading("Cajas y Bancos");
		$data['script']  = script('jquery.js');
		$data["script"] .= script('superTables.js');
		$data['head']    = $this->rapyd->get_head();

		$this->load->view('view_ventanas', $data);
	}
     function dataedit(){
		
		$this->rapyd->load("dataedit");	
        			
		$edit = new DataEdit("Informaci&oacute;n de la Caja o Banco ", "bancos");
		$edit->back_url = site_url("ventas/bancos/filteredgrid");
				
        $edit->tipo = new dropdownField("Tipo", "tipo");
		$edit->tipo->style='width:200px;';
		$edit->tipo->option("B","Banco");
        $edit->tipo->option("C","Caja");
        $edit->tipo->option("O","Otros");
        
        $edit->banco = new inputField('Codigo', 'codigo');
		$edit->banco->size = 10;
		$edit->banco->rule = 'required|strtoupper';
        $edit->banco->mode = 'autohide';
		$edit->banco->maxlength=5;
		
		$edit->nombre = new inputField('Nombre', 'descrip');
		$edit->nombre->size = 50;
		$edit->nombre->rule = 'required|strtoupper';
		$edit->nombre->maxlength=50;
        
        $edit->numero = new inputField('N&uacute;mero de Cuenta', 'cuenta');
		$edit->numero->size = 50;
		$edit->numero->maxlength=50;
        
        $edit->rif = new inputField('RUC', 'rifb');
		$edit->rif->size = 15;
		$edit->rif->maxlength=13;
        
		$edit->contacto = new inputField('Contacto', 'contacto');
		$edit->contacto->size = 50;
		$edit->contacto->rule = 'strtoupper';
		$edit->contacto->maxlength=100;
        
        $edit->telefono1 = new inputField('Tel&eacute;fono', 'telefono');
		$edit->telefono1->size = 50;
		$edit->telefono1->maxlength=30;
                
        $edit->moneda = new dropdownField("Moneda", "moneda");
		$edit->moneda->style='width:230px;';
		$edit->moneda->option("","Seleccione la moneda" );
		$edit->moneda->option("02","DOLAR" );
		$edit->moneda->option("01","SOL");
		$edit->moneda->rule = 'required';
        
		$edit->buttons("back","save","modify","undo");
		$edit->build();
               
		$data['content'] =$edit->output;
		$data['title']   =  heading("Cajas y Bancos");
		$data["head"]    = script("jquery.pack.js").script("plugins/jquery.numeric.pack.js").script("plugins/jquery.floatnumber.js").$this->rapyd->get_head();
		$this->load->view('view_ventanas', $data);
			
	}
}
?>
